<template>
  <div class="home-content">
    <div class="home-content__container">
      <div class="home-content__left">
        <div class="home-content__left-head">
          <ul>
            <li>推荐</li>
            <li>最新</li>
            <li>热榜</li>
          </ul>
        </div>

        <div class="home-content__left-list">
          <article-card
            v-for="item in articleCardList"
            style="margin-top: 20px"
            :article="item"
          ></article-card>
        </div>
      </div>

      <div class="home-content__right">
        <div class="home-content__right-list1">
          <div class="home-content__right-list1-title">
            <span>近期评神用户</span>
          </div>
          <div class="home-content__right-list1-users">
            <div class="list1-users-item" v-for="i in 3">
              <img
                style="width: 40px; height: 40px; border-radius: 50%"
                src="https://p6-passport.byteacctimg.com/img/user-avatar/ddd95876f23c6e8ab56cab355f78a059~300x300.image"
                alt="用户头像"
              />

              <div style="margin-left: 10px">
                <div style="font-size: 0.8rem">轩小浅</div>
                <span style="font-size: 0.8rem">高级构架师</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import ArticleCard, { ArticleCardProps } from '/@/views/Article/components/ArticleCard.vue'

import { articleCard } from '/@/api/article/articleCard'
import { onMounted, ref } from 'vue'

// const article = {
//   articleId: 12, // 文章ID
//   pushDate: '545884848000', // 发布时间
//   nickName: '轩小浅', // 发表用户名
//   tagName: 'Vue.js', // 标签
//   title: '面试自我介绍5句话公式', // 文章题目
//   articleSummary:
//     '开源的世界每天都丰富多彩，2022年前端领域会有什么新的挑战？下面是我们整理的20个有趣的开源项目，希望当中有您想要收藏的那一个。', // 文章摘要
//   likeCount: 199, // 文章点赞数
//   commentCount: 100, // 文章评论数
//   readCount: 999, // 文章浏览量
//   articleImg: 'https://s3.bmp.ovh/imgs/2022/03/8967922835e4c803.png'
// }
// let dataList: any = ref([article, article, article, article, article])

let articleCardList = ref<Array<ArticleCardProps>>()

onMounted(() => {
  articleCard(localStorage.getItem('userId') ?? '-1').then((res) => {
    articleCardList.value = res.data
  })
})
</script>

<style scoped lang="scss">
.home-content {
  width: 100%;
  background-color: #f1f2f9;

  overflow: hidden;

  .home-content__container {
    margin: 0 auto;
    width: 100%;

    // height: 1000px;
    max-width: 960px;

    display: flex;
    .home-content__left {
      width: 740px;

      .home-content__left-head {
        width: 740px;

        width: 100%;
        height: 46px;
        margin-top: 10px;
        background-color: white;

        box-sizing: border-box;

        padding: 10px;

        ul {
          display: flex;

          height: 100%;

          align-items: center;

          li {
            padding: 0 1rem;
            /*text-align: center;*/
            flex-shrink: 0;
            box-sizing: border-box;

            color: #909090;

            border-right: 1px solid #eaeaea;

            font-size: 0.9rem;

            user-select: none;

            cursor: pointer;

            &:hover {
              color: #007fff;
            }

            &:first-child {
              color: #007fff;
            }

            &:last-child {
              border-right: 0;
            }
          }
        }
      }

      .home-content__left-list {
        width: 100%;
      }
    }

    .home-content__right {
      width: 285px;
      height: 500px;

      margin-top: 10px;
      margin-left: 10px;

      // background-color: white;

      display: flex;

      .home-content__right-list1 {
        width: 100%;

        height: 250px;

        background-color: white;

        &-title {
          width: 100%;

          height: 42px;

          span {
            width: 100%;
            display: inline-block;

            box-sizing: border-box;

            padding: 1rem 1.3rem;
            font-size: 0.8rem;

            border-bottom: 1px solid hsla(0, 0%, 59.2%, 0.1);
          }
        }

        &-users {
          display: flex;

          box-sizing: border-box;

          padding: 1rem 1.3rem;

          flex-direction: column;

          .list1-users-item {
            width: 100%;
            height: 70px;

            // background-color: black;

            display: flex;
          }
        }
      }
    }
  }
}
</style>
